package com.example.zhu.controller;

import com.example.zhu.result.Result;
import com.example.zhu.service.LessonService;
import com.example.zhu.vo.LessonVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/lesson")
@CrossOrigin
public class LessonController {
    @Autowired
    private LessonService lessonService;
    @GetMapping("/getAll")
    public Result<List<LessonVO>> selectAll(){
        List<LessonVO> list = lessonService.selectAll();
        return Result.success(list);
    }

    @GetMapping("/getByCondition")
    public Result<List<LessonVO>> selectByTypeAndTime(@RequestParam String productId, @RequestParam String start, @RequestParam String end){
        log.info("productId: {},start: {},end: {}",productId,start,end);
        List<LessonVO> list = lessonService.getByCondition(productId,start,end);
        return Result.success(list);
    }


    @DeleteMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable Integer id){
        log.info("删除的订单id:{}",id);
        return lessonService.deleteById(id);
    }


}
